#ifndef AI_PLAYER_HPP_INCLUDED
#define AI_PLAYER_HPP_INCLUDED

#include <vector>

#include "battle.hpp"
#include "pathfind.hpp"
#include "player.hpp"

namespace game {

class commander_unit;

class ai_player : public player {
public:
	explicit ai_player(wml::const_node_ptr node);

	void play_turn(scenario& s);

private:
	void control_commander(scenario& s, commander_unit_ptr commander);

	void move_unit(scenario& s, unit_ptr unit, const hex::route& route);
	void attack_unit(const hex::location& attacker, const hex::location& defender);

	void display_moves(const scenario& scenario);

	void set_value(const std::string& key, const variant& value);

	std::string target_;
	hex::location target_hex_;
	bool passive_;
	int min_rating_for_leader_attack_;
	int unit_spacing_;
	int enemy_distance_weighting_;

	struct MoveOption {
		unit_ptr unit;
		hex::location move_to;
		int rating;
	};

	int evaluate_move(const unit& unit, const hex::location& move_to) const;
	MoveOption find_best_move(unit_ptr unit, const hex::route_map& routes) const;

	int value_spacing(const hex::location& unit_loc, const hex::location& commander_loc) const;
};

}

#endif
